<template>
    <div class="comment">
        <div class="title">
            <span>评论</span>
            <span>({{dataLength}})</span>
        </div>
        <div class="announce">
            <img v-if="userData.user_img!=null" :src="userData.user_img" alt="">
            <img v-else src="~assets/img/default_img.jpg" alt="">
            <input type="text" ref="inputs" v-model="inputContent" placeholder="说点什么吧">
            <button @click="announces()">发表</button>
        </div>
    </div>
</template>

<script>
    export default {
        name: "comment",
        props:['userData','dataLength'],
        data(){
            return{
                inputContent:''
            }
        },
        methods:{
            announces(){
                if (this.userData&&!localStorage.getItem('id')&&!localStorage.getItem('token')){
                    this.$toast.fail('请先登录')
                    return
                }
                this.$emit('commentPost',this.inputContent)
                this.inputContent = ''
            },
            fouceInput(){
                this.$refs.inputs.focus()
            }
        },
    }
</script>

<style scoped lang="less">
    .comment{
        margin-top: 6.452vw;
        padding: 0 3.226vw 0 1.613vw;
        .title{
            span:nth-of-type(1){

            }
            span:nth-of-type(2){
                color: #aaa;
                margin-left: 1.613vw;
            }
        }
        .announce{
            display: flex;
            align-items: center;
            img{
                border-radius: 50%;
                width: 9.677vw;
                height: 9.677vw;
            }
            input{
                border: 0;
                outline: none;
                background-color: #f4f4f4;
                border-radius: 3.871vw;
                height: 9.677vw;
                margin-left: 1.613vw;
                width: 50.516vw;
                font-size: 3.871vw;
                padding: 0 3.226vw;
            }
            button{
                height: 8.4vw;
                width: 18.6vw;
                line-height: 7.4vw;
                background: #fb7299;
                border: none;
                border-radius: 4.8vw;
                font-size: 3.83333vw;
                text-align: center;
                margin: 3vw auto 0;
                margin-bottom: 12px;
                color: white;
            }
        }
    }

</style>